<template>
  <div class="work-order-search mt15">
    <Vmask :maskTitle='maskTitle' :maskData='maskData' :showMask='showMask' :maskWidth='maskWidth' @FnMask='FnMask'></Vmask>
    <!-- 工单查询 -->
    <div class="search mb15">
      <div class="row clearfix lh40">
        <!-- <div class="row-item clearfix fl mr15">
              <span class="row-item-title fl">部门名称：</span>
              <span class="fl span-input">
                <el-input placeholder="请输入内容" v-model="getPermissionsDetailsDate"></el-input>
              </span>
            </div>-->
        <div class="row-item clearfix fl mr15 mb15">
          <span class="row-item-title fl">工单编号：</span>
          <span class="fl span-input">
            <el-input placeholder="请输入内容" v-model.trim="orderNo"></el-input>
          </span>
        </div>
        <div class="row-item clearfix fl mr15 mb15">
          <span class="row-item-title fl">客户号码：</span>
          <span class="fl span-input">
            <el-input placeholder="请输入内容" v-model.trim="phoneNum"></el-input>
          </span>
        </div>
        <div class="row-item clearfix fl mr15 mb15">
          <span class="row-item-title fl">ESN编号/订单编号：</span>
          <span class="fl span-input">
            <el-input placeholder="请输入内容" v-model.trim="esnOrderNo"></el-input>
          </span>
        </div>
        <div class="row-item fl">
          <span class="row-item-title fl">城市地区：</span>
          <span class="fl mr15">
            <el-cascader v-model="cityarea" :options="CityareaList" :props="{ checkStrictly: true,label:'pcaName',value:'pcaName',children:'sysPcaList' }" clearable></el-cascader>
          </span>
        </div>
      </div>
      <div class="row clearfix mb15">
        <div class="row-item fl mr15">
          <span class="row-item-title">创建时间：</span>
          <span class="timer">
            <el-date-picker v-model="timer" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
            </el-date-picker>
          </span>
        </div>
        <div class="row-item fl">
          <span class="row-item-title">处理部门：</span>
          <span class="mr15">
            <el-select v-model="orderDeptId" clearable placeholder="请选择" style="width:auto">
              <el-option v-for="item in handleDepartmentList" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </span>
        </div>
        <div class="row-item fl">
          <span class="row-item-title">工单类型：</span>
          <span class="">
            <el-select v-model="searchWorkOderType" clearable placeholder="请选择" style="width:auto">
              <el-option :value="1" label="紧急"></el-option>
              <el-option :value="2" label="升级"></el-option>
            </el-select>
          </span>
        </div>
      </div>

      <div class="row clearfix lh40">
        <div class="row-item fl">
          <span class="row-item-title fl">工单分类：</span>
          <span class="fl mr15">
            <el-cascader v-model="classificationName" :options="jobClassificationList" :props="{ checkStrictly: true,label:'label',value:'label' }" clearable></el-cascader>
          </span>
        </div>
        <div class="row-item clearfix fl mr15">
          <span class="row-item-title fl">工单内容：</span>
          <span class="fl span-input">
            <el-input placeholder="请输入内容" v-model.trim="orderContent"></el-input>
          </span>
        </div>
        <div class="row-item fl ml15 pl15">
          <el-button type="primary" @click="FnSearch">查询</el-button>
        </div>
        <div class="row-item fl ml15">
          <el-button type="primary" @click="FnAddWorkOrder">生成工单</el-button>
        </div>
      </div>

    </div>
    <div class="content-table">
      <div class="content-table-title">
        <div class="row clearfix">
          <div class="row-item fr">
            <el-button type="primary" @click="FnExport" v-if="getPermissionControl.workOrderSearchExport">导出</el-button>
          </div>
        </div>
      </div>
      <ShowTable :tableData='tableData' :selections='selections' :lableList='lableList' :talLength='talLength' :pageSize='pageSize' :pageNum='pageNum' @getSortableFn='getSortableFn'></ShowTable>
    </div>
  </div>
</template>

<script>
import { mapActions, mapGetters } from 'vuex';

import ShowTable from '../components/table/show-table'
import Vmask from '@/views/components/v-mask/v-mask'
import { GetWorkOrderByConditions, Code, AddWorkOrder, GetClassificationList, LockWorkOrder, ReleaseWorkOrder, AddAdditionalComment, AddHandleComment, GetCityAreaList } from '@/axios/api'
import { mixin } from '@/mixin/mixin';
export default {
  name: '',
  mixins: [mixin],
  data() {
    return {
      defaultProps: {
        children: 'sysPcaList',
        label: 'pcaName'
      },
      orderStatus: '',
      orderDeptId: '',
      searchWorkOderType: '',//工单类型
      classificationName: [],//工单分类
      orderContent: '',//工单内容
      orderStatusFlagList: [
        { label: '成功', value: '1' },
        { label: '失败', value: '2' },
        { label: '待跟进', value: '3' },
        { label: '未处理', value: '4' },
      ],
      showMask: false,
      maskTitle: '',
      maskWidth: '800px',
      maskData: {},
      orderNo: '',//工单编号：
      phoneNum: '',//客户号码：
      esnOrderNo: '',//ESM编号
      cityarea: [], //城市地区
      timer: '',
      tableData: [
        // {
        //   overtime:true,//超时
        //   n1:'工单类型11',
        //   n2:'流水号',
        //   n3:'工单编号',
        //   n4:'登记人姓名',
        //   n5:'电话号码',
        //   n6:'创建时间',
        //   n7:'处理部门',
        //   n8:'催单',
        //   n9:'工单状态',
        //   details:'1'
        // }
      ],
      selections: false,//是否多选
      lableList: {//表头
        overtime: '是否超时',
        n1: '工单类型',
        n2: 'ESN编号/订单编号',
        n3: '工单编号',
        n4: '登记人姓名',
        n5: '电话号码',
        n6: '创建时间',
        n7: '处理部门',
        n8: '催单',
        n9: '工单状态',
        n10: '城市地区',
        width: '120px',
        operation: '操作',
      },
      talLength: 0,//总条数
      pageSize: 15,
      pageNum: 1,
      lastData: {},
      jobClassificationList: [],//工单分类
      CityareaList: [], //城市分类
    }
  },
  props: [],
  created() {
    this.FnSearch()
    this.FnGetjobClassificationList()
    this.FnGetCityAreaList()
    this.userMessage = JSON.parse(window.sessionStorage.getItem('user')).data;
    // 角色：4-话务员，5-审核员，6-处理员，7-回访员
    //   
    // 归档-状态-已处理
    // 审核-状态-已审核
    // 处理（回访）-状态-跟进中
    var deptId = window.sessionStorage.getItem('user') ? JSON.parse(window.sessionStorage.getItem('user')).data.deptId : '';

    switch (deptId) {
      case 4:
        this.jobTypeList = [{ label: '工单审核', value: '1' }];
        this.shoWorderDeptId = false
        break;
      case 5:
        this.shoWorderDeptId = false;
        this.orderDeptId = '1';
        this.jobTypeList = [{ label: '工单审核', value: '1' }, { label: '工单处理', value: '2' }, { label: '工单归档', value: '4' }]
        break;
      case 6:
        this.shoWorderDeptId = false;
        this.orderDeptId = '2';
        this.jobTypeList = [{ label: '工单审核', value: '1' }, { label: '工单处理', value: '2' }, { label: '工单回访', value: '3' }]
        break;
      case 7:
        this.shoWorderDeptId = false;
        this.orderDeptId = '3';
        this.jobTypeList = [{ label: '工单处理', value: '2' }, { label: '工单回访', value: '3' }, { label: '工单归档', value: '4' }]
        break;
      case 1:
        this.shoWorderDeptId = true;
        this.orderDeptId = '';
        this.jobTypeList = [{ label: '工单审核', value: '1' }, { label: '工单处理', value: '2' }, { label: '工单回访', value: '3' }, { label: '工单归档', value: '4' }]
        break;
      case 2:
        this.shoWorderDeptId = true;
        this.orderDeptId = '';
        this.jobTypeList = [{ label: '工单审核', value: '1' }, { label: '工单处理', value: '2' }, { label: '工单回访', value: '3' }, { label: '工单归档', value: '4' }]
        break;
      case 3:
        this.shoWorderDeptId = true;
        this.orderDeptId = '';
        this.jobTypeList = [{ label: '工单审核', value: '1' }, { label: '工单处理', value: '2' }, { label: '工单回访', value: '3' }, { label: '工单归档', value: '4' }]
        break;
      default:
        this.jobTypeList = [{ label: '工单审核', value: '1' }, { label: '工单处理', value: '2' }, { label: '工单回访', value: '3' }, { label: '工单归档', value: '4' }]
        break;
    }
    // console.log(this.FnGetjobClassificationList())
  },
  mounted() {

    var that = this;
    // window.addEventListener('beforeunload', function(e) { 
    //   var e = window.event || e;
    //   if(that.maskData.additionalComments) {
    //     that.FnReleaseWorkOrder(that.maskData.row)
    //   }
    //   e.returnValue =("确定离开当前页面吗？")
    // })
    // var a = this.Fn()
    // console.log(a['PromiseValue'],'a')
    // console.log(this.Fn())
  },
  methods: {
    FnGetTime() {//获取当前时间
      // var time = new Date();
      var date = new Date()
      var Y = date.getFullYear() + '-'
      var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
      var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
      var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
      var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
      var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds())
      return Y + M + D + h + m + s
    },
    // 获取工单分类方法
    FnGetjobClassificationList() {
      GetClassificationList().then(res => {
        if (res.state == Code) {
          this.jobClassificationList = res.data.slice()
        }
      })
    },
    // 获取省市区数据
    FnGetCityAreaList() {
      GetCityAreaList().then(res => {
        if (res.state == Code) {

          this.CityareaList = res.data.slice()

        }
      })
    },
    FnAddWorkOrder() {//生成工单--弹框
      var user = JSON.parse(window.sessionStorage.getItem("user")).data.username
      this.showMask = true;
      this.maskTitle = '生成工单';
      this.maskWidth = '600px';
      // console.log(this.jobClassificationList)
      this.maskData = {
        createdTime: this.FnGetTime(),
        addWorkOrder: true,
        defaultBox: true,
        handlePerson: user,//登记人
        jobClassification: [],//工单分类
        clientName: '',
        phoneNum: '',//
        esnOrderNo: '',
        orderContent: '',
        remark: '',
        workOderType: '',
        workOderTypeList: this.workOderTypeList,
        jobClassificationList: this.jobClassificationList,
        CityareaList: this.CityareaList, //省市区列表 
        cityarea: [] // 省市区
      }
    },
    FnSearch() {
      this.pageNum = 1
      var createTimeStart = '';
      var createTimeEnd = '';
      if (this.timer) {
        createTimeStart = this.timer[0]
        createTimeEnd = this.timer[1]
      }
      this.lastData = {
        createTimeStart,//创建时间
        createTimeEnd,//
        orderNo: this.orderNo,//工单号
        esnOrderNo: this.esnOrderNo,//ESN工单号
        orderDeptId: this.orderDeptId,
        phoneNum: this.phoneNum,//客户号码
        workOderType: this.searchWorkOderType,//查询工单类型
        classificationName: this.classificationName.join('/'),//工单分类
        pcaName: this.cityarea.join('/'), //城市地区
        orderContent: this.orderContent,//工单内容
      }
      this.FnGetWorkOrderByConditions()
    },
    FnOvertime(e) {//返回是否超时-86400000-一天的时间戳
      var date = (new Date()).getTime();//当前时间戳
      var overtime = Date.parse(e);
      var isOverTime = ((date - overtime) - (86400000 * 1)) > 0 ? true : false
      return isOverTime
    },
    FnGetWorkOrderByConditions() {//查找工单
      GetWorkOrderByConditions({
        createTimeStart: this.lastData.createTimeStart,//创建时间
        createTimeEnd: this.lastData.createTimeEnd,//
        orderNo: this.lastData.orderNo,//工单号
        esnOrderNo: this.lastData.esnOrderNo,//ESN工单号
        phoneNum: this.lastData.phoneNum,//客户号码
        orderDeptId: this.lastData.orderDeptId,
        workOderType: this.lastData.workOderType,//查询工单类型
        classificationName: this.lastData.classificationName,//查询工单分类
        pcaName: this.lastData.pcaName, // 查询城市地区
        orderContent: this.lastData.orderContent,//查询工单内容
        orderByTime: 2,
        pageNum: this.pageNum,
        pageSize: this.pageSize
      }).then(res => {
        // console.log(res)
        if (res.state == Code) {
          this.tableData = [];
          this.talLength = res.count;
          var list = res.data.slice();
          console.log(list);
          list.forEach((v) => {
            this.tableData.push({
              overtime: v.orderDeptId == 4 ? false : this.FnOvertime(v.updateTime),//是否超时
              n1: this.workOderType(v.workOderType),//工单类型
              n2: v.esnOrderNo,//esn订单编号
              n3: v.orderNo,//工单编号
              n4: v.registerPerson,//登记人姓名
              n5: v.phoneNum,//电话号码
              n6: v.createTime,//创建时间
              n7: this.handleDepartment(v.orderDeptId),//处理部门 4 归档
              n8: v.additional && v.additional.length ? v.additional.length : '-',//催单
              n9: this.workOrderStatus(v.orderStatus),//工单状态
              n10: v.pcaName, //城市地区
              details: '1',
              additionalComments: this.FnHasHandleWorkOrder(v.orderDeptId),//处理工单 v.orderDeptId==4?false:true
              row: v
            })
          })
          // console.log(this.tableData)
        }
      })
    },
    FnHasHandleWorkOrder(e) {//是否能有处理工单的按钮 this.userMessage.deptId登录的。 e是当前数据的orderDeptId归档 ||this.userMessage.deptId==4
      var has = false;
      if (this.userMessage.deptId == 5 && e == 1) {
        has = true
        return has
      } else if (this.userMessage.deptId == 6 && e == 2) {
        has = true
        return has
      } else if (this.userMessage.deptId == 7 && e == 3) {
        has = true
        return has
      } else if (this.userMessage.deptId == 1 || this.userMessage.deptId == 2 || this.userMessage.deptId == 3) {
        has = true
        return has
      } else if (this.userMessage.deptId == 4 && (e != 4)) {
        has = true
        return has
      } else if (this.userMessage.deptId == 4 && (e == 4)) {
        has = false
        return has
      }
      return has
    },
    FnExport() {//导出   
      window.location.href = `${this.$prefix}/order/exportWorkOrder?createTimeStart=${this.lastData.createTimeStart}&createTimeEnd=${this.lastData.createTimeEnd}&orderNo=${this.lastData.orderNo}&esnOrderNo=${this.lastData.esnOrderNo}&phoneNum=${this.lastData.phoneNum}&orderDeptId=${this.lastData.orderDeptId}&orderByTime=2&workOderType=${this.lastData.workOderType}&classificationName=${this.lastData.classificationName}&pcaName=${this.lastData.pcaName}
      &orderContent=${this.lastData.orderContent}&Authorization=${this.getUser.token}`
    },
    FnWorkOrderDetails(e) {
      console.log(e)
      this.showMask = true;
      this.maskTitle = "工单详情"
      this.maskWidth = '920px';
      this.maskData = {
        workOrderDetails: true,
        onlyFalse: true,
        createTime: e.createTime,//创建日期
        registerPerson: e.registerPerson,//登记人：
        workOderNo: e.orderNo,//工单编号
        phoneNum: e.phoneNum,//电话号码
        clientName: e.clientName,//客户姓名
        esnOrderNo: e.esnOrderNo,//订单编号
        orderNameClassification: e.orderNameClassification,//工单分类
        cityarea: e.pcaName, // 城市地区
        workOderType: this.workOderType(e.workOderType),//工单类型
        orderStatus: this.workOrderStatus(e.orderStatus),//工单状态
        orderContent: e.orderContent,//工单内容
        remark: e.remark,//备注
        additional: this.FnAdditional(e.additional),//添加附加意见
        handle: this.FnAdditional(e.handle),//处理意见记录
      }
    },
    FnAdditional(e) {//添加附加意见
      var arr = e.length ? e.slice() : []
      // console.log(e)
      var list = [];
      arr.forEach((v) => {
        v.role = this.FnReturnRole(v.handleDeptId)
        v.handleStatus = this.handleDepartment(v.handleStatus)
        list.push(v)
      })
      return list
    },
    getSortableFn(e) {//表的事件
      if (e.type == "details") {//工单详情
        this.FnWorkOrderDetails(e.content.row)
      } else if (e.type == 'pageSize') {
        this.pageSize = e.content;
        this.FnGetWorkOrderByConditions()
      } else if (e.type == 'pageNum') {
        this.pageNum = e.content;
        this.FnGetWorkOrderByConditions()
      } else if (e.type == 'additionalComments') {//附加意见
        this.FnIsLock(e.content.row);//先看看是否锁定
      }
    },
    FnIsLock(e) {//是否锁定
      this.showMask = true;
      this.maskWidth = '920px';
      this.maskTitle = "附加意见"
      this.maskData = {
        additionalBox: true,
        additionalComments: true,
        createTime: e.createTime,//创建日期：
        registerPerson: e.registerPerson,//登记人：
        workOderNo: e.orderNo,//工单编号
        phoneNum: e.phoneNum,//
        clientName: e.clientName,//客户姓名：
        esnOrderNo: e.esnOrderNo,//订单编号：
        orderNameClassification: e.orderNameClassification,//工单分类：
        cityarea: e.pcaName,   //城市分类
        workOderType: e.workOderType,//工单类型：
        workOderTypeList: this.workOderTypeList,//工单类型
        jobTypeList: this.jobTypeList,
        orderStatus: e.orderStatus,//工单状态：
        workOrderStatusList: this.workOrderStatusList,
        orderContent: e.orderContent,//工单内容：
        remark: e.remark,//备注：
        additional: this.FnAdditional(e.additional),//添加附加意见记录
        handle: this.FnAdditional(e.handle),//处理意见记录
        additionalText: '',//添加附加意见
        addHandlingText: '',//添加处理意见
        orderDeptId: '',//工单流转/归档
        // addHandlingBox:this.userMessage.deptId==4?false:true,//能否附加意见
        row: e
      }
      return
      LockWorkOrder({
        orderNo: e.orderNo
      }).then(res => {
        // console.log(res)
        if (res.state == Code) {
          this.$message.success(res.data)
          this.showMask = true;
          this.maskWidth = '920px';
          this.maskTitle = "附加意见"
          this.maskData = {
            additionalBox: true,
            additionalComments: true,
            createTime: e.createTime,//创建日期：
            registerPerson: e.registerPerson,//登记人：
            workOderNo: e.orderNo,//工单编号
            phoneNum: e.phoneNum,//
            clientName: e.clientName,//客户姓名：
            esnOrderNo: e.esnOrderNo,//订单编号：
            orderNameClassification: e.orderNameClassification,//工单分类：
            workOderType: e.workOderType,//工单类型：
            workOderTypeList: this.workOderTypeList,//工单类型
            jobTypeList: this.jobTypeList,
            orderStatus: e.orderStatus,//工单状态：
            workOrderStatusList: this.workOrderStatusList,
            orderContent: e.orderContent,//工单内容：
            remark: e.remark,//备注：
            cityarea: '',   //城市分类
            additional: this.FnAdditional(e.additional),//添加附加意见记录
            handle: this.FnAdditional(e.handle),//处理意见记录
            additionalText: '',//添加附加意见
            addHandlingText: '',//添加处理意见
            orderDeptId: '',//工单流转/归档
            // addHandlingBox:this.userMessage.deptId==4?false:true,//能否附加意见
            row: e
          }
        }
      })
    },
    FnAdditionalText(e) {//添加附加意见不能为空
      // console.log(e,'添加处理意见提交的数据')
      // console.log(this.userMessage,'this.userMessage')
      if (e.additionalText === '') {
        this.$message.error("添加附加意见不能为空");
        return
      }

      // handleStatus:e.orderStatus,//当前处理状态:1:审核; 2跟进中; 3:已处理;
      AddAdditionalComment({
        handleDeptId: this.userMessage.deptId,//当前登记人(部门)
        handleDetail: e.additionalText,//附加详情
        handleId: this.userMessage.orderNo,//当前登记人(工号)
        handlePerson: this.userMessage.username,//当前登记人(姓名)
        workOderNo: e.row.orderNo,//工单编号
      }).then(res => {
        // console.log(res)
        if (res.state == Code) {
          this.$message.success("添加附加意见成功");
          this.maskData.additional.push({
            createTime: res.data.createTime,
            handlePerson: res.data.handlePerson,
            role: this.FnReturnRole(res.data.handleDeptId),
            handleDetail: e.additionalText,
          })
          this.maskData.additionalText = ''
        }
      })
    },
    FnMask(e) {//弹框
      // console.log(e)
      // console.log(this.maskData)
      if (e.type == "false") {
        if (this.maskData.additionalComments) {
          // this.FnReleaseWorkOrder(this.maskData.row);//释放工单
        }
        this.showMask = false;
        this.maskData = {}
        this.FnGetWorkOrderByConditions()
      } else {
        if (e.content.addWorkOrder) {//生成工单
          //   console.log(e);
          //   return false
          this.FnSaveWorkOrder(e.content)
        } else if (e.type == "additional") {//添加附加意见：
          this.FnAdditionalText(this.maskData);//添加附加意见：
        } else if (e.type == "addHandling") {//添加处理意见：
          this.FnAddHandling(this.maskData);//添加处理意见：
        } else if (e.type == "workOrderFlow") {//工单流转
          this.FnWorkOrderFlow(this.maskData);//工单流转
        }
      }
    },

    //
    FnWorkOrderFlow(e) {
      // console.log(e,'工单流转')
      if (e.orderDeptId === '') {
        this.$message.error("未选择工单流转")
        return
      }
      AddWorkOrder({
        createTime: e.createdTime,
        handlePerson: this.userMessage.username,//当前登记人(姓名)
        phoneNum: e.phoneNum,//电话
        clientName: e.clientName,//客户姓名：
        esnOrderNo: e.esnOrderNo,//ESM编号/订单编号：
        orderContent: e.orderContent,//工单内容：
        handleDetail: e.orderContent,//工单内容：------
        orderNameClassification: e.orderNameClassification,
        workOderType: e.workOderType,//工单类型
        remark: e.remark,
        orderDeptId: e.orderDeptId,
        orderStatus: e.orderStatus,
        isUsed: '0',
        orderNo: e.row.orderNo,
        // handleStatus:'1',
        handleId: this.userMessage.orderNo,//-----
        handleDeptId: this.userMessage.deptId,//-----
        registerDeptId: this.userMessage.deptId,//------
        registerId: this.userMessage.orderNo,
        registerPerson: e.row.registerPerson,
        additional: JSON.stringify([{
          handlePerson: this.userMessage.username,//当前登记人(姓名)
          handleId: this.userMessage.orderNo,//-----
          handleDeptId: this.userMessage.deptId,//-----
          // handleStatus:'1',
          handleDetail: e.orderContent
        }]
        )
      }).then(res => {
        if (res.state == Code) {
          this.$message.success("处理工单成功，工单已释放");
          this.showMask = false;
          this.maskData = {}
          this.FnSearch()
        }
      })
    },
    FnAddHandling(e) {//添加处理意见：
      // console.log(e,'添加处理意见')
      if (e.addHandlingText === '') {
        this.$message.error("添加处理意见内容不能为空")
        return
      }
      AddHandleComment({
        handleDeptId: this.userMessage.deptId,//当前登记人(部门)
        handleDetail: e.addHandlingText,//附加详情
        handleId: this.userMessage.orderNo,//当前登记人(工号)
        handlePerson: this.userMessage.username,//当前登记人(姓名)
        workOderNo: e.row.orderNo,//工单编号
      }).then(res => {
        // console.log(res)
        this.$message.success("添加处理意见成功");
        this.maskData.handle.push({
          createTime: res.data.createTime,
          handlePerson: res.data.handlePerson,
          role: this.FnReturnRole(res.data.handleDeptId),
          handleDetail: res.data.handleDetail,
        })
        this.maskData.addHandlingText = ''
      })
    },
    FnReleaseWorkOrder(e) {//释放工单
      ReleaseWorkOrder({
        orderNo: e.orderNo
      }).then(res => {
        // console.log(res);
        if (res.state == Code) {
          this.$message.success(res.data)
          this.showMask = false;
          this.maskData = {}
          this.FnGetWorkOrderByConditions()
        }
      })
    },
    FnSaveWorkOrder(e) {//生成工单--提交
      //   console.log(e)
      if (e.createdTime === '' || e.handlePerson === '' || e.clientName === '' || e.phoneNum === '' || e.esnOrderNo === '' || e.jobClassification.length == 0 || e.orderContent === '' || e.workOderType === '') {
        this.$message.error("参数不能为空")
        return
      }
      var orderNameClassification = ''
      e.jobClassification.forEach((v, i) => {
        if (i == 0) {
          orderNameClassification = v
        } else {
          orderNameClassification = orderNameClassification + '/' + v
        }
      })
      let pcaName = ''
      e.cityarea.forEach((v, i) => {
        if (i == 0) {
          pcaName = v
        } else {
          pcaName = pcaName + '/' + v
        }
      })
      var user = JSON.parse(window.sessionStorage.getItem("user"))
      //   return false
      AddWorkOrder({
        createTime: e.createdTime,
        handlePerson: e.handlePerson,//当前登记人(姓名)
        phoneNum: e.phoneNum,//电话
        clientName: e.clientName,//客户姓名：
        esnOrderNo: e.esnOrderNo,//ESM编号/订单编号：
        orderContent: e.orderContent,//工单内容：
        handleDetail: e.orderContent,//工单内容：------
        orderNameClassification,
        pcaName,
        workOderType: e.workOderType,//工单类型
        remark: e.remark,
        orderDeptId: '1',
        orderStatus: '1',
        isUsed: '0',
        handleStatus: '1',
        handleId: user.data.orderNo,//-----
        handleDeptId: user.data.deptId,//-----
        registerDeptId: user.data.deptId,//------
        registerId: user.data.orderNo,
        registerPerson: e.handlePerson,
        additional: JSON.stringify([{
          handlePerson: e.handlePerson,//当前登记人(姓名)
          handleId: user.data.orderNo,//-----
          handleDeptId: user.data.deptId,//-----
          handleStatus: '1',
          handleDetail: e.orderContent
        }]
        )
      }).then(res => {
        if (res.state == Code) {
          this.$message.success("生成工单成功");
          this.showMask = false;
          this.maskData = {}
          this.FnSearch()
        }
      })
    }
  },
  components: {
    ShowTable,
    Vmask
  },
  computed: {
    ...mapGetters(['getPermissionControl', 'getUser'])
  },
  watch: {

  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang='scss' scoped>
</style>
